<!DOCTYPE html>
<html lang="en">
	<meta charset="UTF-8">
	<title>树状数组模板</title>
<pre>#define lowbit(x) (x&(-x))
typedef int val;
val tr[nmax];
inline void add(int x, val v) {while(x<=n){tr[x]+=v;x+=lowbit(x);}}
inline val query(int x) {val ret=0;while(x){ret+=tr[x];x-=lowbit(x);}return ret;}</pre></html>